package com.OrderingSystem.handler;

import com.OrderingSystem.exception.SellException;
import com.OrderingSystem.utils.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 全局异常处理：所有的控制器异常负责处理
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = RuntimeException.class)
    @ResponseBody
    public Result SellException(SellException e) {
        return Result.error(e.getMessage());
    }
}
